/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.commons.cli;

import cz.mzk.kramerius.commons.PidExctractor;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dom4j.DocumentException;

/**
 *
 * @author Martin Řehánek <rehan at mzk.cz>
 */
public class Main {

    private static String USAGE = "použití: java - jar KrameriusCommons.jar VSTUPNI_SOUBOR VYSTUPNI_SOUBOR XPATH";

    public static void main(String[] args) {
        try {
            extractPidsByXpath(args[0], args[1], args[2]);
        } catch (Throwable ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            System.err.println(USAGE);
        }
    }

    private static void extractPidsByXpath(String inputFileName, String outFileName, String xpath) throws IOException, FileNotFoundException, DocumentException {
        File inFile = new File(inputFileName);
        File outFile = new File(outFileName);
        PidExctractor extractor = new PidExctractor(inFile, xpath);
        extractor.extractPidsAndSaveToFile(outFile);
    }
}
